package service.impl;

import dao.PersonDao;
import dao.UserInfoDao;
import entity.Person;
import org.springframework.stereotype.Service;
import service.MainService;
import entity.Userinfo;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("userService")
public class MainServiceImpl implements MainService {
    @Resource(name = "userInfoDao")
    private UserInfoDao userInfoDao;
    @Resource(name = "personDao")
    private PersonDao personDao;
    @Override
    public List<Userinfo> GetAll(Map<String,Object> map){
        return userInfoDao.GetAll(map);
    }

    @Override
    public int GetPageCount(String name) {
        return userInfoDao.GetCount(name);
    }

    @Override
    public List<Person> GetPersonInfo(String name,long sex,int pageSize,int PageNumber) {
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("offset",(PageNumber-1)*pageSize);
        map.put("limit",pageSize);
        map.put("name",name);
        map.put("sex",sex);
        return  personDao.GetPersonInfo(map) ;
    }

    @Override
    public int GetPersonCount(Person person) {
        return personDao.GetCount(person);
    }
}
